﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 高斯正反算
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnGeoToProj_Click(object sender, EventArgs e)
        {
            double lon, lat;
            if (double.TryParse(tbLon.Text, out lon))
            {
                if (double.TryParse(tbLat.Text, out lat))
                {
                    double x, y, centerLon;
                    int zoneIndex;
                    Guass2 g = new Guass2();
                    if (radioButton1.Checked)
                        g.ZoneWide = 3;
                    else
                        g.ZoneWide = 6;
                    g.GaussPrjCalculate(lon, lat, out x, out y);
                    g.CaleZoneIndex(lon, out zoneIndex, out centerLon);
                    tbX.Text = x.ToString();
                    tbY.Text = y.ToString();
                    label5.Text = "带号：" + zoneIndex + ",中央经线：" + centerLon;
                }
            }
        }

        private void btnProjToGeo_Click(object sender, EventArgs e)
        {
            double x, y;
            if (double.TryParse(tbX.Text, out x))
            {
                if (double.TryParse(tbY.Text, out y))
                {
                    double lon, lat, centerLon;
                    int zoneIndex;
                    Guass2 g = new Guass2();
                    if (radioButton1.Checked)
                        g.ZoneWide = 3;
                    else
                        g.ZoneWide = 6;
                    g.GaussPrjInvCalculate(x, y, out lon, out lat);
                    g.CaleZoneIndex(lon, out zoneIndex, out centerLon);
                    tbLon.Text = lon.ToString();
                    tbLat.Text = lat.ToString();
                    label5.Text = "带号：" + zoneIndex + ",中央经线：" + centerLon;
                }
            }
        }
    }
}
